package model.person;

import java.io.Serializable;
import javax.persistence.*;

/**
 * The primary key class for the person database table.
 * 
 */
@Embeddable
public class PersonPK implements Serializable {
	//default serial version id, required for serializable classes.
	private static final long serialVersionUID = 1L;

	@Column(name="p_code", unique=true, nullable=false, length=20)
	private String pCode;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="p_birth", unique=true, nullable=false)
	private java.util.Date pBirth;

	public PersonPK() {
	}
	public PersonPK(String pCode, java.util.Date pBirth) {
		this.pCode = pCode;
		this.pBirth = pBirth;
	}
	
	public String getPCode() {
		return this.pCode;
	}
	public void setPCode(String pCode) {
		this.pCode = pCode;
	}
	public java.util.Date getPBirth() {
		return this.pBirth;
	}
	public void setPBirth(java.util.Date pBirth) {
		this.pBirth = pBirth;
	}

	public boolean equals(Object other) {
		if (this == other) {
			return true;
		}
		if (!(other instanceof PersonPK)) {
			return false;
		}
		PersonPK castOther = (PersonPK)other;
		return 
			this.pCode.equals(castOther.pCode)
			&& this.pBirth.equals(castOther.pBirth);
	}

	public int hashCode() {
		final int prime = 31;
		int hash = 17;
		hash = hash * prime + this.pCode.hashCode();
		hash = hash * prime + this.pBirth.hashCode();
		
		return hash;
	}
}